<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:pr="http://primefaces.prime.com.tr/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <h:head>
        <title>#{prefBean.webshopname} - #{title} </title>
        <meta name="description" content="#{prefBean.description}"/>
        <meta name="keywords" content="#{prefBean.keywords}"/>
        <meta name="author" content="#{prefBean.author}" />
        <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
        <link rel="stylesheet" href="style/template.css" type="text/css"/>
        <link rel="stylesheet" href="#{customcss}" type="text/css"/>

    </h:head>

    <h:panelGroup rendered="#{prefBean.siteOffline}">
        <body>
            <div id="offline"><br/>#{prefBean.offlineMessage}</div>
        </body>
    </h:panelGroup>
    <h:panelGroup rendered="#{!prefBean.siteOffline}">
        <body>
            <div id="mainLeft"></div>
            <div id="mainRight"></div>

            <div id="mainCenter">
                <div id="header">
                    <div id="leftHeader">
                        <div id="topMenu">
                            <h:form>
                                &nbsp;
                                <h:commandLink id="account" action="account">
                                    <h:outputText value="My Account"/>
                                </h:commandLink>&nbsp;
                                <h:commandLink id="orders" action="orders">
                                    <h:outputText value="View Orders"/>
                                </h:commandLink>&nbsp;
                                &nbsp;
                                <h:commandLink id="cart" action="cart">
                                    <h:outputText value="View Cart"/>
                                </h:commandLink>   &nbsp;
                                <h:commandLink id="employee" action="employeemain" rendered="#{userModelBean.isEmployee()}">
                                    <h:outputText value="Employee"/>   &nbsp;
                                </h:commandLink>
                                <h:link id="admin" outcome="/admin/main" rendered="#{userModelBean.isAdmin()}">
                                    <h:outputText value="Admin"/>   &nbsp;
                                </h:link>
                            </h:form>
                        </div>
                        <div id="logoContainer">
                            <h:form>
                                <h:commandLink action="main">
                                    <h:graphicImage id="logo"
                                                    alt="JARD Webshop"
                                                    url="/img/logo.png">
                                    </h:graphicImage>     
                                </h:commandLink>&nbsp;


                            </h:form>
                        </div>
                    </div>
                    <div id="rightHeader">

                        <!-- Rendered if user is NOT online -->
                        <h:panelGroup rendered="#{not userModelBean.isLoggedIn()}">
                            <div id="topLogin">
                                <h:form>
                                    <h:inputText id="loginfield"  size="10" maxlength="25" value="#{loginBackingBean.username}" title="User name"/>
                                    <h:inputSecret id="loginpassfield" size="10" maxlength="25" value="#{loginBackingBean.password}" title="Password"/>
                                    <h:commandButton type="Submit" value="Login" action="#{loginBackingBean.doLogin()}" styleClass="button"/>
                                </h:form>
                                <h:form id="registerlink">
                                    <h:commandLink id="register" action="register">
                                        <h:outputText value="Register"/>
                                    </h:commandLink>
                                </h:form>

                            </div>

                        </h:panelGroup>
                        <!-- Rendered if user is online -->
                        <h:panelGroup rendered="#{userModelBean.isLoggedIn()}">
                            <div id="topLogin">
                                <div id="loggedin">Logged in as:      
                                    <h:form id="usernameform">
                                        <h:commandLink id="username" action="settings">
                                            <h:outputText value="#{userModelBean.name}"/>
                                        </h:commandLink>
                                    </h:form>
                                    <div id="logOffDiv">
                                        <h:form>
                                            <h:commandButton type="Submit" value="Log Out" action="#{loginBackingBean.doLogout()}" styleClass="button"/>
                                        </h:form>
                                    </div>
                                </div>        
                            </div>

                        </h:panelGroup>


                        <div id="cart">
                            <pr:panel id="cartPanel" style="width: 290px">
                            <h:form>
                                <h:outputText value="You have #{cartModel.count} items in your"/>
                                <h:commandLink id="cart" action="cart">
                                    <h:outputText value="cart"/>
                                </h:commandLink>
                            </h:form>
                                </pr:panel>
                        </div>

                        <!--div id="searchBar">
                            <form id="searchform" action="search" method="POST">
                                <input type="text" name="Search" size="10" title="Search" value="Search..." onClick="this.value=''" class="inputfield">
                                </input>
                                <input type="submit" value="Search" class="button"/>
                            </form>
                        </div-->
                    </div>
                </div>

                <div id="bodyContainer">
                    <div id="leftColumn">

                        <h:form>
                            <pr:tree value="#{categoryBackingBean.root}" var="node" 
                                     id="tree" selectionMode="single">
                                <pr:ajax event="select" update="list" listener="#{productListModel.nodeListener}"/>  
                                <pr:treeNode>
                                    <h:outputText value="#{node}"/>
                                </pr:treeNode>
                            </pr:tree>
                        </h:form>
                    </div>



                    <div id="rightColumn">
                        <h:panelGroup rendered="#{prefBean.showAlertMessage}"> 
                            <div id="alertDiv">
                                #{prefBean.alertMessage} 
                            </div>
                        </h:panelGroup>
                        <div id="pageDiv">
                            <ui:insert name="content">Default</ui:insert>
                        </div>
                    </div>
                </div>
                <div id="footer">

                    <h:form>
                        <h:commandLink id="contact" action="contact">
                            <h:outputText value="Contact us"/>
                        </h:commandLink>&nbsp;
                        <h:commandLink id="terms" action="terms">
                            <h:outputText value="Terms And Agreements"/>
                        </h:commandLink>&nbsp;
                        <h:commandLink id="shipping" action="shipping">
                            <h:outputText value="Shipping Info"/>
                        </h:commandLink>

                    </h:form>

                </div>
            </div>

        </body>

    </h:panelGroup>
</html>


